/**
 * @program: LeetCode
 * @description: LeetCode :
 * @author: WXY
 * @create: 2023-01-02 21:05
 * @Version 1.0
 **/
public class code_countPrimes {
    public int countPrimes(int n) {
        boolean[] arr = new boolean[n];
        int ans = 0;
        for (int i = 2; i * i < n; i++) {
            if (arr[i]) continue;
            ans++;
            for (int j = i; j < n; j += i) {
                arr[j] = true;
            }
        }
        return ans;
    }
}
